Repository navigation
fix(ra): seal the gate-verified ACME method into domainValidation - #75
Merged
Merged
Conversation
The domain-control challenge gate is any-of — either the DNS-01 TXT record or the HTTP-01 resource satisfies it — but both AGENT_REGISTERED event builders hardcoded domainValidation to "ACME-DNS-01", so an agent whose domain control was proven via HTTP-01 was sealed into the append-only log with the wrong method token. The gate result could not simply be read at emit time: the event is built in a later HTTP call (verify-dns) where the verified type is out of scope, and CertificateOrder had no field to carry it. Persist the satisfied challenge type on the order when the gate passes (migration 012, cert_order_verified_challenge), and derive the sealed token from it in both the V1 and V2 builders. Rows that predate recording omit the field — the schemas mark it optional in both lanes, and an append-only log must never carry a fabricated method token. Fixes #61 Signed-off-by: Connor Snitker <csnitker@godaddy.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a structural RA attestation defect by persisting which ACME challenge type actually satisfied the domain-control gate (DNS-01 vs HTTP-01) and using that recorded value when sealing the terminal AGENT_REGISTERED event’s attestations.domainValidation on both V1 and V2 TL lanes.
Changes:
- Add
CertificateOrder.VerifiedChallenge+ helpers to record the satisfied challenge at gate-pass time and map it to the TL method token (ACME-DNS-01/ACME-HTTP-01). - Persist the verified challenge through SQLite (migration + store codec) so it survives the
verify-acme→verify-dnscall boundary. - Update both V1 and V2 event builders to derive
domainValidationfrom the persisted value (and omit it when unrecorded), with regression coverage for HTTP-01, DNS-01, and pre-recording rows.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/ra/service/v1event.go | V1 builder now sources domainValidation from the recorded verified challenge (instead of a constant). |
| internal/ra/service/order_flow_test.go | Adds end-to-end regression tests ensuring HTTP-01 vs DNS-01 flows seal the correct domainValidation, and unrecorded rows omit it. |
| internal/ra/service/lifecycle.go | Records the satisfied challenge type on the aggregate at gate pass time and uses it in the V2 builder. |
| internal/domain/order.go | Introduces VerifiedChallenge, RecordVerifiedChallenge(), and ACMEMethodToken() mapping for TL emission. |
| internal/domain/order_test.go | Adds unit tests for the new order/challenge-type helpers and updated IsZero() behavior. |
| internal/adapter/store/sqlite/order_persistence_test.go | Extends SQLite round-trip coverage to include the new verified-challenge field through UPDATE paths. |
| internal/adapter/store/sqlite/migrations/012_cert_order_verified_challenge.sql | Adds the cert_order_verified_challenge column (NULL = not recorded). |
| internal/adapter/store/sqlite/agent.go | Wires the new column through row decode/encode and INSERT/UPDATE statements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kperry-godaddy
approved these changes
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #61.
The domain-control challenge gate (verify-acme) is any-of — either the DNS-01 TXT record or the HTTP-01 resource satisfies it — but both AGENT_REGISTERED event builders hardcoded
domainValidation: "ACME-DNS-01", so an agent whose domain control was proven via HTTP-01 was sealed into the append-only log with a wrong method token.As the issue notes, the defect is structural, not a wrong literal: the gate computes the satisfied challenge type, but the event is built in a later HTTP call (verify-dns) where that result is out of scope, and
CertificateOrderhad no field to carry it across the boundary.Pre-implementation shape diff
Wire shape touched:
attestations.domainValidationon the AGENT_REGISTERED inner event. Canonical schemas (internal/tl/service/schemas/V1.json,V2.json, both mirrored from the reference TL contract):with
Attestations.required: []in both lanes. Differences introduced by this change, called out explicitly:ACME-DNS-01orACME-HTTP-01, chosen by which artifact actually satisfied the gate. Both tokens are already in the enum on both lanes; no schema change.ACME-TLS-ALPN-01remains never-emitted (the RA offers no TLS-ALPN challenge).ACME-DNS-01. Omission is valid in both lanes (required: [],omitemptyon both Go structs) and is the honest encoding of "method unknown" — the log is append-only, so a fabricated token could never be corrected.ACME-DNS-01; we now emit the faithful token. The reference schema enumerates all three methods, so the value is shape-compatible. This should sync with the ANS-1 spec wording flagged in specs(ans-1): rewrite Registration & Lifecycle against the reference implementation (v0.2.0) ans-spec#32.Changes
CertificateOrder.VerifiedChallenge+RecordVerifiedChallenge();ChallengeType.ACMEMethodToken()mapping (DNS_01→ACME-DNS-01,HTTP_01→ACME-HTTP-01, unknown→empty);IsZero()covers the new field.gateOrderChallenges): a passing gate records the satisfied type on the order and logs it at INFO (agentId,fqdn,challengeType). Every downstream path already persists the order, including the async-provider ISSUING park.012_cert_order_verified_challenge.sqladdsagent_registrations.cert_order_verified_challenge(NULL = not recorded); wired through the SQLite agent store codec and INSERT/UPDATE.buildAgentRegisteredEvent, V1buildAgentRegisteredV1Event): derivedomainValidationfrom the recorded type instead of the constant.Testing
DOMAIN_VALIDATIONprobes, forcing the gate down the HTTP-01 path: the sealed event must carryACME-HTTP-01on both V1 and V2 lanes, and the satisfied type must be persisted at verify-acme time. Both tests were confirmed to fail against the previous hardcoded builders.ACME-DNS-01, unrecorded rows omitting the field from the canonical bytes, the SQLite round-trip (NULL→empty, recorded value survives the UPDATE path), and the new domain methods.make checkpasses: fmt, vet, golangci-lint, coverage 90.4% (≥90% gate),internal/domainat 100%.make test-raceclean on the touched packages.🤖 Generated with Claude Code